using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;

namespace shfa.snomtastic.data
{
    public partial class SqlDataProvider
    {

        public Guid InsertFirmware(Guid modelId, Guid configurationId, string version, string description, string bootLoader, Guid upgardeTo, bool sendXML, string fileUrl)
		{
            return new Guid(Convert.ToString(SqlHelper.ExecuteScalar(ConnectionString, "sp_FirmwareInsert", GetNull(modelId), GetNull(configurationId), version, description, bootLoader, GetNull(upgardeTo), sendXML, fileUrl)));
		}

        public int UpdateFirmware(Guid firmwareId, Guid modelId, Guid configurationId, string version, string description, string bootLoader, Guid upgardeTo, bool sendXML, string fileUrl)
		{
            return Convert.ToInt32(SqlHelper.ExecuteScalar(ConnectionString, "sp_FirmwareUpdate", GetNull(firmwareId), GetNull(modelId), GetNull(configurationId), version, description, bootLoader, GetNull(upgardeTo), sendXML, fileUrl));
		}

        public int DeleteFirmware(Guid firmwareId) 
		{
            return Convert.ToInt32(SqlHelper.ExecuteScalar(ConnectionString, "sp_FirmwareDelete", firmwareId));
		}

        public DataRow SelectFirmware(Guid firmwareId) 
        {    
			DataSet ds = SqlHelper.ExecuteDataset(ConnectionString, "sp_FirmwareSelect", firmwareId);
            if (ds.Tables.Count > 0)
                if (ds.Tables[0].Rows.Count > 0)
                    return ds.Tables[0].Rows[0];

            return null;
		}

		public DataTable SelectFirmwares() 
		{
            return SqlHelper.ExecuteDataset(ConnectionString, "sp_FirmwareSelectAll").Tables[0];
        }

		public DataTable SelectFirmwaresByConfiguration(Guid configurationId) 
		{
            return SqlHelper.ExecuteDataset(ConnectionString, "sp_FirmwareSelectByConfiguration", configurationId).Tables[0];
        }

		public DataTable SelectFirmwaresByModel(Guid modelId) 
		{
            return SqlHelper.ExecuteDataset(ConnectionString, "sp_FirmwareSelectByModel", modelId).Tables[0];
        }

    }

}
